home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2006 May
/
PCWMAY06.iso
/
Software
/
Freeware
/
First Page 2006 3.00
/
fp2006-final-3.00-setup.exe
/
{app}
/
Iscripts
/
Forms Misc
/
radio-quest-val.izs
< prev
next >
Wrap
Text File
|
2005-09-28
|
4KB
|
159 lines
<!NOWIZARD>
<!TITLE>Radio Question Validator
<!/TITLE>
<!DESCRIPTION>This script validates that every Radio Button question on the form has been answered. No modifications needed!<!/DESCRIPTION>
<!CATEGORY>Forms<!/CATEGORY>
<!SCRIPT>
<!-- START OF SCRIPT -->
<!-- HOW TO INSTALL RADIO QUESTION VALIDATOR:
1. Copy code into the HEAD section of document
2. Put last coding into the BODY section of document -->
<!-- STEP ONE: Add code into HEAD section of document -->
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- Original: David Blackledge -->
<!-- Web Site: http://David.Blackledge.com -->
<!-- Begin
function checkRadios() {
var el = document.forms[0].elements;
for(var i = 0 ; i < el.length ; ++i) {
if(el[i].type == "radio") {
var radiogroup = el[el[i].name]; // get the whole set of radio buttons.
var itemchecked = false;
for(var j = 0 ; j < radiogroup.length ; ++j) {
if(radiogroup[j].checked) {
itemchecked = true;
break;
}
}
if(!itemchecked) {
alert("Please choose an answer for "+el[i].name+".");
if(el[i].focus)
el[i].focus();
return false;
}
}
}
return true;
}
// End -->
</script>
</HEAD>
<!-- STEP TWO: Add code into BODY section of document -->
<BODY>
<FORM onsubmit="return checkRadios(this);">
Blue:
<input type="radio" value="1" name="blue">
<input type="radio" value="2" name="blue">
<input type="radio" value="3" name="blue">
<input type="radio" value="4" name="blue">
<input type="radio" value="5" name="blue">
<BR>
Red:
<input type="radio" value="1" name="red">
<input type="radio" value="2" name="red">
<input type="radio" value="3" name="red">
<input type="radio" value="4" name="red">
<input type="radio" value="5" name="red">
<BR>
<input type="submit" value="check" name="button">
</FORM>
<!-- END OF SCRIPT -->
<!/SCRIPT>
<!PREVIEW>
<!-- START OF SCRIPT -->
<!-- HOW TO INSTALL RADIO QUESTION VALIDATOR:
1. Copy code into the HEAD section of document
2. Put last coding into the BODY section of document -->
<!-- STEP ONE: Add code into HEAD section of document -->
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- Original: David Blackledge -->
<!-- Web Site: http://David.Blackledge.com -->
<!-- Begin
function checkRadios() {
var el = document.forms[0].elements;
for(var i = 0 ; i < el.length ; ++i) {
if(el[i].type == "radio") {
var radiogroup = el[el[i].name]; // get the whole set of radio buttons.
var itemchecked = false;
for(var j = 0 ; j < radiogroup.length ; ++j) {
if(radiogroup[j].checked) {
itemchecked = true;
break;
}
}
if(!itemchecked) {
alert("Please choose an answer for "+el[i].name+".");
if(el[i].focus)
el[i].focus();
return false;
}
}
}
return true;
}
// End -->
</script>
</HEAD>
<!-- STEP TWO: Add code into BODY section of document -->
<BODY>
<FORM onsubmit="return checkRadios(this);">
Blue:
<input type="radio" value="1" name="blue">
<input type="radio" value="2" name="blue">
<input type="radio" value="3" name="blue">
<input type="radio" value="4" name="blue">
<input type="radio" value="5" name="blue">
<BR>
Red:
<input type="radio" value="1" name="red">
<input type="radio" value="2" name="red">
<input type="radio" value="3" name="red">
<input type="radio" value="4" name="red">
<input type="radio" value="5" name="red">
<BR>
<input type="submit" value="check" name="button">
</FORM>
<!-- END OF SCRIPT -->
<!/PREVIEW>
<!RELATED>NONE<!/RELATED>